﻿<?php

use yii\helpers\Html;
use yii\helpers\Url;
use backend\widgets\GridView;
use yii\widgets\Breadcrumbs;
use yii\jui\DatePicker;
use yii\widgets\ActiveForm;
use backend\models\service\CateService as Cate;

$this->title = '编辑推文';
?>

<!DOCTYPE html>
<html lang="zh">
    <head>
        <meta charset="UTF-8" />

        <meta http-equiv="X-UA-Compatible" content="ie=edge" />
        <title>编辑</title>

        <link href="../../css/common/base.css" rel="stylesheet">
        <link href="../../css/common/common.css" rel="stylesheet">
        <link href="../../css/common/bootstrap.min.css" rel="stylesheet">
        <link href="../../css/common/daterangepicker-bs3.css" rel="stylesheet">

        <link href="../../css/PassList.css" rel="stylesheet">
        <link href="../../css/ThePass.css" rel="stylesheet">

        <script type="text/javascript" src="../../js/jquery-2.1.1.min.js"></script>
        <script type="text/javascript" src="../../js/bootstrap.min.js"></script>

        <script type="text/javascript" src="../../js/extendPagination.js"></script>
        <script type="text/javascript" src="../../js/moment.js"></script>
        <script type="text/javascript" src="../../js/daterangepicker.js"></script>
    </head>
    <body>
        <div class="newPass">
            <h4>推文编辑<k class="tw_shuji"><?php echo isset($info['novel_name']) ? $info['novel_name'] : ''; ?></k></h4>
            <input type="hidden" id="t_id" value="<?php echo $info['id']; ?>">
            <ul>
                <li>
                <o class="tw_title">标题名称</o>：
                <select id="title">
                    <option value="">点击选择推文标题</option>
                    <?php foreach ($title_list as $l): ?>
                        <option <?php echo isset($info['title_id']) && $info['title_id'] == $l['id'] ? 'selected = "selected"' : ''; ?> value="<?php echo $l['id']; ?>"><?php echo $l['name']; ?></option>
                    <?php endforeach; ?>
                </select>
                </li>

                <li>
                    <button type="button" class="btn btn-primary tw_bottoN">点击选择\更换推文图片</button>				
                </li>

                <li class="tw_Img">
                    <img src="<?php echo $info['img_url']; ?>" />					
                </li>	


                <li>
                <o>是否强制关注公众号</o><span>*</span>：
                <div class="checkbox">
                    <label class="radio-inline">
                        <input  disabled="disabled" type="radio" <?php echo $info['is_force_focus_wechat'] == 1 ? 'checked' : ''; ?> name="inlineRadioOptions" id="inlineRadio1" value="1" class="code_type"> 是
                    </label>
                    <label class="radio-inline">
                        <input  disabled="disabled" type="radio" <?php echo $info['is_force_focus_wechat'] == 0 ? 'checked' : ''; ?> name="inlineRadioOptions" id="inlineRadio2" value="0" class="code_type"> 否
                    </label>
                </div>
                </li>


                <li class="tw_Gz_in">
                <o>强制关注章节</o>：
                <input type="text" class="form-control code_id" id="chapter" disabled="disabled" value="<?php echo $info['chapter_id']; ?>">
                </li>

                <li class="tw_Gz_in">
                <o>微信回复关键字</o>：
                <input type="text" class="form-control code_id" id="kw" disabled="disabled" value="<?php echo $info['kw']; ?>">
                </li>

                <li class="lassLI ">
                    <button type="button" class="btn btn-primary tw_QDOK">保存创建</button>
                    <button type="button" class="btn btn-primary tw_QX">取消</button>
                </li>

            </ul>
            <div class="IMgDiv">
<!--                <p class="IMgDiv_P">
                    <button type="button" class="btn btn-primary IMgDiv_QDOK">保存创建</button>
                    <button type="button" class="btn btn-primary IMgDiv_QX">取消</button>
                </p>-->
                <?php foreach ($pic_list as $v): ?>
                    <img src="<?php echo $v['img_url']; ?>">
                <?php endforeach; ?>
                <button class="b" style="position:absolute;top:1%;left:96%;background-color:green;">取消</button>
            </div>
        </div>	
        <div class="bottom"></div>
    </body>

</html>

<script>
    $(".tw_QX").click(function () {
        window.history.back(-1);
    })

    $(".tw_bottoN").click(function () {
        $(".IMgDiv").show();
    });
    
    $(".IMgDiv img").click(function(){
        var url = $(this).attr('src');
        $(".tw_Img img").attr('src',url);
        $(".IMgDiv").hide();
    });
    
    $(".b").click(function(){
        $(".IMgDiv").hide();
    });
    var act = '<?php echo $act;?>';
    $(".tw_QDOK").click(function () {
        var id = $("#t_id").val();
       
        var title_id = $("#title").val();
        if( title_id == ''){
            alert('标题名称不能为空，请选择');
            return false;
        }
        var img_url = $(".tw_Img>img").attr('src');
        if( img_url == ''){
            alert('推文图片不能为空，请选择');
            return false;
        }
        $.ajax({
            url: "/tweet/create",
            type: "post",
            dataType: "json",
            data: {id: id, title_id: title_id, img_url: img_url},
            success: function (data) {
                if (data.status == 0) {
                    alert(data.msg);
                    if(act == 'tweet'){
                        location.href="/tweet/index"
                    }else{
                        location.href="/novel/index"
                    }
                }
            }
        });
    });

</script>
